package com.itheima.manager;

import com.itheima.domain.UmsResource;
import com.itheima.domain.UmsResourceCategory;
import com.itheima.service.db.UmsResourceCategoryService;
import com.itheima.util.R;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ZhuHongKai
 * @version 1.0
 * @ClassName UmsResourceController
 * @date 2022/11/13 1:44
 */
@Component
public class UmsResourceCategoryManager {

    @DubboReference
    UmsResourceCategoryService umsResourceCategoryService;

    public R listAll() {
        List<UmsResourceCategory> list =  umsResourceCategoryService.listAll();
        return R.success(list);
    }

    /**
     * 修改后台资源分类
     * @param id
     * @return
     */
    public R resourceCategoryUpdate(Long id,UmsResourceCategory umsResourceCategory) {
        umsResourceCategoryService.resourceCategoryUpdate(id,umsResourceCategory);
        return R.success("修改成功");
    }

    /**
     * 根据ID删除后台资源
     * @param id
     * @return
     */
    public R delete(Long id) {
        umsResourceCategoryService.delete(id);
        return R.success("删除成功");
    }

    /**
     * 添加后台资源分类
     * @param umsResourceCategory
     * @return
     */
    public R save(UmsResourceCategory umsResourceCategory) {
        umsResourceCategoryService.save(umsResourceCategory);
        return R.success("添加成功");
    }
}
